import Vue from 'vue'
import Vuex from 'vuex'

import {
  eduClassesStudentQuery,
  eduClassesStudentDelete,
  eduClassesStudentAdd,
  eduClassesStudentAddBatch,
  eduClassesStudentUpdate,
} from '@/api/admin/courseLibrary/eduClassesStudent.js'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async queryEduClassesStudent({ commit }, listQuery) {
    let res = await eduClassesStudentQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteEduClassesStudent({ commit }, row) {
    let res = await eduClassesStudentDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addEduClassesStudent({ commit }, data) {
    let res = await eduClassesStudentAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addBatchEduClassesStudent({ commit }, data) {
    let res = await eduClassesStudentAddBatch(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateEduClassesStudent({ commit }, data) {
    let res = await eduClassesStudentUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
